package main

import (
	"fmt"
	"time"
)

func main() {
	//获取时间错
	timestamp := time.Now().Unix()
	//1545959664
	fmt.Println(timestamp)
	//格式化为字符串，tm为time类型
	tm := time.Unix(timestamp, 0)
	fmt.Println(tm.Format("2006-01-02 03:04:05 PM"))
	fmt.Println(tm.Format("02/01/2006 15:04:05 PM"))

	tm2, _ := time.Parse("2006-01-02 03:04:05", "2018-12-28 09:20:00")
	fmt.Println(tm2.Unix())
}
